import { ref, computed } from 'vue'
import { defineStore } from 'pinia'
import { LS_Pro } from '@/util/storage'
import { useRouter } from 'vue-router'
import { getuserInfo } from '@/api/login'

export const useLoginStore = defineStore('counter', () => {
  const userid = LS_Pro.get('userid');
  const nickname = ref<string>('')
  const router=useRouter()
  const getuserInfoHander = async () =>{
      let res = await getuserInfo(userid)
      if(res.code !=200) {
        return nickname.value=' '
      }
      nickname.value=res.data[0].nickname
  }
  return {nickname,getuserInfoHander}
})

export default useLoginStore
